
const protecteds = new WeakMap()
// 也可以统一定义私有属性


class Common {
     //private
  #host = "https://houdunren1.com";

  constructor(host) {
    this.host = host
    // protecteds.set(this, {
    //   host: this.host
    // })
    this.protecteds = host
  }



  set host(url) {
    if (!/^https?:\/\//i.test(url)) {
      throw new Error("网址错误");
    }
    protecteds.set(this, {...protecteds.get(this), host:url})
  }

  get host() {
    return protecteds.get(this).host
  }

}

class Article extends Common {
   //private
  #host = "https://houdunren2.com";

  constructor(host) {
    super(host)
    this.host = host ;

    // 私有属性不能被继承
    console.log(this.#host)
    console.log(this.host)
    
    this.#check(host);
  }
  #check2 = function(host) {
    console.log('check2', this, host)
  }

  #check = (host) => {
    console.log('check1', this, host)
  }


  lists() {
    return `${this.host}/article`;
  }
}
var article = new Article('http://baidu.com');
console.log(article.lists()); //https://houdunren.com/article
